﻿using System.Configuration;

namespace DeVierKoeden.Dynamicweb.CreateSite
{
  internal static class Configuration
  {
    /// <summary>
    /// Used to build up the full path to the new site's Admin folder.
    /// </summary>
    internal const string StartBrowserArguments = @"http://{0}/Admin";

    /// <summary>
    /// Gets a value from the application's app.config file.
    /// </summary>
    /// <param name="key">The key to retrieve.</param>
    /// <returns>The requested value from the configuration file when found.</returns>
    internal static string GetAppSetting(string key)
    {
      return ConfigurationManager.AppSettings[key];
    }

    internal static bool PreSelectUseStandardAppPool
    {
      get
      {
        string setting = GetAppSetting("PreSelectUseStandardAppPool");
        if (string.IsNullOrEmpty(setting))
        {
          return false;
        }
        return bool.Parse(setting);
      }
    }

    internal static bool PreSelectTakeAppsWebConfig
    {
      get
      {
        string setting = GetAppSetting("PreSelectTakeAppsWebConfig");
        if (string.IsNullOrEmpty(setting))
        {
          return false;
        }
        return bool.Parse(setting);
      }
    }

    internal static bool PreSelectUpdateHostsFile
    {
      get
      {
        string setting = GetAppSetting("PreSelectUpdateHostsFile");
        if (string.IsNullOrEmpty(setting))
        {
          return false;
        }
        return bool.Parse(setting);
      }
    }
  }
}
